﻿using System;
using System.Windows.Forms;

namespace MovieBrowser.Presentation.List.SearchDialogs
{
    public partial class SearchRatingDialog : Form
    {
        public double StartRating { get { return ratingFrom.Rating; } }
        public double EndRating { get { return ratingTo.Rating; } }
        public bool SearchRating { get { return chkRating.Checked; } }

        public int StartYear { get { return (int)yearStart.Value; } }
        public int EndYear { get { return (int)yearEnd.Value; } }
        public bool SearchYear { get { return chkYear.Checked; } }

        public SearchRatingDialog()
        {
            InitializeComponent();
        }

        private void ClSearchClick(object sender, EventArgs e)
        {
            Hide();
        }

        private void ChkRatingCheckedChanged(object sender, EventArgs e)
        {
            var val = chkRating.Checked;
            ratingFrom.Enabled = val;
            ratingTo.Enabled = val;
            ratingStart.Enabled = val;
            ratingEnd.Enabled = val;
        }

        private void NumericUpDown1ValueChanged(object sender, EventArgs e)
        {
            ratingFrom.Rating = (double)ratingStart.Value;
        }

        private void NumericUpDown2ValueChanged(object sender, EventArgs e)
        {
            ratingTo.Rating = (double)ratingStart.Value;
        }

        private void RatingFromRatingValueChanged(object sender, NymphsLib.RatingControl.RatingChangedEventArgs e)
        {
            ratingStart.Value = (decimal)ratingFrom.Rating;
        }

        private void RatingToRatingValueChanged(object sender, NymphsLib.RatingControl.RatingChangedEventArgs e)
        {
            ratingEnd.Value = (decimal)ratingTo.Rating;
        }

        private void ChkYearCheckedChanged(object sender, EventArgs e)
        {
            var val = chkYear.Checked;
            yearStart.Enabled = val;
            yearEnd.Enabled = val;
        }
    }
}
